﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace DeliverySolution.General
{
    public class WebUtilities
    {
        public static string BuildAbsoluteLink(string relativeUri)
        {
            Uri uri = HttpContext.Current.Request.Url;
            string app = HttpContext.Current.Request.ApplicationPath;
            if (!app.EndsWith("/"))
            {
                app += "/";
            }
            relativeUri = relativeUri.TrimStart('/');
            return HttpUtility.UrlPathEncode(string.Format("{0}://{1}:{2}{3}{4}", uri.Scheme, uri.Host, uri.Port, app, relativeUri));
        }
    }
}